/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: #ffffff;
    min-height: 100vh;
    color: #333333;
}

.container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 导航栏样式 */
.navbar {
    background: #000000;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #cccccc;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffffff;
}

.nav-links {
    display: flex;
    gap: 1rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    color: #cccccc;
    border-radius: 4px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.nav-link:hover {
    background: #333333;
    color: #ffffff;
}

.nav-link.active {
    background: #ffffff;
    color: #000000;
}

/* 主要内容区域 */
.main-content {
    flex: 1;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* 页面标题 */
.page-header {
    text-align: center;
    margin-bottom: 3rem;
    color: #333333;
}

.page-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.page-header p {
    font-size: 1.1rem;
    color: #666666;
}

/* 内容网格 */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 3rem;
}

/* 区域样式 */
.upload-section,
.search-section {
    background: #ffffff;
    border: 1px solid #cccccc;
    border-radius: 8px;
    padding: 1.5rem;
}

.section-header {
    margin-bottom: 1.5rem;
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #333333;
    margin-bottom: 0.5rem;
}

/* 上传区域 */
.upload-area {
    border: 2px dashed #cccccc;
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-area:hover {
    border-color: #999999;
    background: #f9f9f9;
}

.upload-area.dragover {
    border-color: #333333;
    background: #f0f0f0;
}

.upload-content h3 {
    font-size: 1.2rem;
    color: #333333;
    margin-bottom: 0.5rem;
}

.upload-content p {
    color: #666666;
    margin-bottom: 1rem;
}

.upload-btn {
    background: #000000;
    color: #ffffff;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.upload-btn:hover {
    background: #333333;
}

/* 进度条 */
.upload-progress {
    margin-top: 1rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: #000000;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.9rem;
    color: #666666;
}

/* 搜索区域 */
.search-input-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.search-input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #cccccc;
    border-radius: 4px;
    font-size: 1rem;
}

.search-input:focus {
    outline: none;
    border-color: #333333;
}

.search-btn {
    background: #000000;
    color: #ffffff;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.search-btn:hover {
    background: #333333;
}

.search-options {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.option-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.option-group label {
    font-size: 0.9rem;
    color: #666666;
}

.option-group select,
.threshold-input,
.number-input {
    padding: 0.5rem;
    border: 1px solid #cccccc;
    border-radius: 4px;
    font-size: 0.9rem;
    width: 120px;
}

.number-input:focus,
.threshold-input:focus {
    outline: none;
    border-color: #000000;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

/* 搜索结果 */
.search-results {
    border: 1px solid #cccccc;
    border-radius: 4px;
    max-height: 400px;
    overflow-y: auto;
}

.search-result-item {
    padding: 1rem;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
}

.search-result-item:hover {
    background-color: #f8f9fa;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.search-result-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.result-index {
    color: #6c757d;
    font-weight: 500;
    font-size: 0.9rem;
}

.search-result-title strong {
    color: #333333;
    font-size: 1rem;
}

.search-result-scores {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    text-align: right;
}

.search-result-score,
.search-result-distance {
    font-size: 0.8rem;
    color: #6c757d;
    background: #f8f9fa;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    white-space: nowrap;
}

.search-result-score {
    background: #e3f2fd;
    color: #1976d2;
}

.search-result-distance {
    background: #f3e5f5;
    color: #7b1fa2;
}

.search-result-content {
    color: #495057;
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #007bff;
}

.search-result-content mark {
    background: #fff3cd;
    color: #856404;
    padding: 0.1rem 0.2rem;
    border-radius: 3px;
    font-weight: 500;
}

.search-result-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.meta-item {
    font-size: 0.75rem;
    color: #6c757d;
    background: #e9ecef;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
}

/* 文档列表区域 */
.documents-section {
    background: #ffffff;
    border: 1px solid #cccccc;
    border-radius: 8px;
    padding: 1.5rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    background: #ffffff;
    color: #333333;
    border: 1px solid #e0e0e0;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.action-btn:hover {
    background: #f8f8f8;
    border-color: #333333;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 文档表格 */
.table-container {
    background: #ffffff;
    border: 1px solid #cccccc;
    border-radius: 8px;
    overflow: hidden;
}

.documents-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.documents-table th {
    background: #f8f9fa;
    color: #333333;
    font-weight: 600;
    padding: 1rem 0.75rem;
    text-align: left;
    border-bottom: 2px solid #e9ecef;
    white-space: nowrap;
}

.documents-table td {
    padding: 0.75rem;
    border-bottom: 1px solid #e9ecef;
    vertical-align: middle;
}

.documents-table tbody tr:hover {
    background: #f8f9fa;
}

.documents-table tbody tr:last-child td {
    border-bottom: none;
}

/* 表格列样式 */
.document-name {
    font-weight: 500;
    color: #333333;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-type-badge {
    background: #000000;
    color: #ffffff;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    display: inline-block;
}

.file-size {
    color: #666666;
    font-family: 'Courier New', monospace;
}

.chunk-count {
    color: #666666;
    text-align: center;
}

.status-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    display: inline-block;
}

.status-badge.status-success {
    background: #d4edda;
    color: #155724;
}

.status-badge.status-processing {
    background: #fff3cd;
    color: #856404;
}

.status-badge.status-error {
    background: #f8d7da;
    color: #721c24;
}

.status-badge.status-unknown {
    background: #e2e3e5;
    color: #383d41;
}

.created-time {
    color: #666666;
    font-size: 0.85rem;
    white-space: nowrap;
}

.actions {
    text-align: center;
}

.delete-btn {
    background: #ffffff;
    border: 1px solid #dc3545;
    color: #dc3545;
    cursor: pointer;
    padding: 0.375rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

.delete-btn:hover {
    background: #dc3545;
    color: #ffffff;
}

.detail-btn {
    background: #ffffff;
    border: 1px solid #007bff;
    color: #007bff;
    cursor: pointer;
    padding: 0.375rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8rem;
    transition: all 0.3s ease;
    margin-right: 0.5rem;
}

.detail-btn:hover {
    background: #007bff;
    color: #ffffff;
}

/* 加载和空状态 */
.loading,
.empty-state {
    text-align: center;
    padding: 2rem;
    color: #666666;
}

.loading {
    font-size: 1rem;
}

.empty-state h3 {
    color: #333333;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: #666666;
}

/* 模态框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: #ffffff;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #f0f0f0;
}

.modal-header h3 {
    color: #333333;
    font-size: 1.2rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #666666;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.modal-close:hover {
    background: #f0f0f0;
    color: #333333;
}

.modal-body {
    padding: 1.5rem;
}

.modal-body p {
    margin-bottom: 0.5rem;
    color: #333333;
}

.warning-text {
    color: #dc3545;
    font-weight: 500;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid #f0f0f0;
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.btn-secondary {
    background: #f8f9fa;
    color: #333333;
    border: 1px solid #cccccc;
}

.btn-secondary:hover {
    background: #e9ecef;
}

.btn-danger {
    background: #dc3545;
    color: #ffffff;
}

.btn-danger:hover {
    background: #c82333;
}

/* 消息提示 */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #333333;
    color: #ffffff;
    padding: 1rem 1.5rem;
    border-radius: 4px;
    z-index: 1001;
    animation: slideIn 0.3s ease;
}

.toast.success {
    background: #28a745;
}

.toast.error {
    background: #dc3545;
}

.toast.warning {
    background: #ffc107;
    color: #333333;
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .navbar {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }

    .nav-links {
        width: 100%;
        justify-content: center;
    }

    .main-content {
        padding: 1rem;
    }

    .page-header h1 {
        font-size: 2rem;
    }

    .content-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .table-container {
        overflow-x: auto;
    }

    .documents-table {
        min-width: 600px;
    }

    .documents-table th,
    .documents-table td {
        padding: 0.5rem 0.375rem;
    }

    .document-name {
        max-width: 150px;
    }

    .search-options {
        flex-direction: column;
        gap: 0.5rem;
    }

    .modal-content {
        margin: 1rem;
        width: calc(100% - 2rem);
    }
}

/* 功能按钮区域 */


/* 大型弹框样式 */
.modal-large {
    max-width: 800px;
    width: 90%;
}

.modal-large .modal-body {
    padding: 2rem;
}

/* 文档详情弹框样式 */
.detail-layout {
    display: flex;
    gap: 2rem;
    min-height: 400px;
}

.detail-left {
    flex: 0 0 350px;
    border-right: 1px solid #e9ecef;
    padding-right: 2rem;
}

.detail-right {
    flex: 1;
    min-width: 0;
}

.detail-info {
    margin-bottom: 1rem;
}

.detail-info h4 {
    color: #333333;
    font-size: 1.1rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid #007bff;
    padding-bottom: 0.5rem;
}

.info-row {
    display: flex;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 600;
    color: #555555;
    min-width: 100px;
    margin-right: 1rem;
}

.info-value {
    color: #333333;
    flex: 1;
    word-break: break-word;
}

.chunks-list {
    margin-top: 1rem;
}

.chunks-list h4 {
    color: #333333;
    font-size: 1.1rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid #28a745;
    padding-bottom: 0.5rem;
}

.chunk-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.chunk-item:last-child {
    margin-bottom: 0;
}

.chunk-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.chunk-id {
    font-weight: 600;
    color: #007bff;
    font-size: 0.9rem;
}

.chunk-size {
    font-size: 0.8rem;
    color: #666666;
    background: #ffffff;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid #dee2e6;
}

.chunk-content {
    color: #333333;
    line-height: 1.5;
    font-size: 0.9rem;
    max-height: 100px;
    overflow-y: auto;
    background: #ffffff;
    padding: 0.75rem;
    border-radius: 4px;
    border: 1px solid #dee2e6;
}

.no-chunks {
    text-align: center;
    color: #666666;
    font-style: italic;
    padding: 2rem;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .modal-large {
        width: 95%;
        margin: 1rem;
    }
    
    .modal-large .modal-body {
        padding: 1rem;
    }
    
    .detail-layout {
        flex-direction: column;
        gap: 1rem;
        min-height: auto;
    }
    
    .detail-left {
        flex: none;
        border-right: none;
        border-bottom: 1px solid #e9ecef;
        padding-right: 0;
        padding-bottom: 1rem;
    }
    
    .detail-right {
        flex: none;
    }
    
    .info-row {
        flex-direction: column;
    }
    
    .info-label {
        min-width: auto;
        margin-right: 0;
        margin-bottom: 0.25rem;
    }
    
    .chunk-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}